<%@ include file="/other/Header.jsp"%>
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<jsp:directive.page import="java.sql.*"/>
<jsp:directive.page import="Connectivity.ConnectionManager"/>
 <%
String status = request.getParameter("status")!=null?request.getParameter("status"):"";
String call_performed_id = request.getParameter("call_performed_id")!=null?request.getParameter("call_performed_id"):"";
//int role_id = session.getValue("role_id").equals(null)?(Integer.parseInt(session.getValue("role_id"))):"3";
 %>

<!DOCTYPE>
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>Call Performed</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<script type="text/javascript" src="<%=basePath%>other/data.js"></script>
    
  </head>
  
  <body>
    <table border=1 width=80%>
    <%
    if(status.equalsIgnoreCase("I"))
    {
    out.println("  <tr><td align=center width=100% colspan=10><font size=4 color=black> SERVICE CALL CLOSED SUCCESSFULL WITH ID ("+call_performed_id+") </font> </td></tr>");
    }
     if(status.equalsIgnoreCase("U"))
    {
    out.println("  <tr><td align=center width=100% colspan=10><font size=4 color=black> UPDATED SUCCESSFULLY </font> </td></tr>");
    }
     if(status.equalsIgnoreCase("D"))
    {
    out.println("  <tr><td align=center width=100% colspan=10><font size=4 color=black> DELETED SUCCESSFULLY </font> </td></tr>");
    }
     if(status.equalsIgnoreCase("m"))
     {
     out.println("  <tr><td align=center width=100% colspan=10><font size=4 color=black> MOVED SUCCESSFULLY </font> </td></tr>");
     }
    %> 
  <tr><td align=center   colspan=7><font size=4 color=Blue> CALL PERFORMED</font></td></tr>
     <tr>
     <td colspan=1><font size=2 color="light pink"><b>Sr.No.</b></font></td>
     <td colspan=1><font size=2 color="light pink"><b>COMPLAINT ID</b></font></td>
     <td colspan=1><font size=2 color="light pink"><b>CUSTOMER NAME</b></font></td>
     <td colspan=1><font size=2 color="light pink"><b>BRANCH</b></font></td>
     <td colspan=1><font size=2 color="light pink"><b>ITEM NAME</b></font></td>
     <td colspan=1><font size=2 color="light pink"><b>ISSUE</b></font></td>
     <td colspan=1><font size=2 color="light pink"><b>EMPLOYEE</b></font></td>
     <% if(role_id <2){%>
     <td colspan=1><font size=2 color="light pink"><b></b></font></td>
     <%} %>
      </tr> 
      
     <%
    
     boolean flag=false;
     int count=0;
     String emp_eid="",call_details="",emp_id1="",cust_id="";
     String complaint_id="-",customer_name="-",area="-",cust_type="-",callentry_id="",item_name="";
    try
    {
    // String calldisplay="select ce.callentry_id,ce.complaint_id,cm.customer_name,cm.area,cn.name,coalesce(ce.call_details,'-'), em.emp_id,cm.customer_id,im.item_name";
	//		calldisplay=calldisplay+" from callentry ce,customer_master cm,call_nature cn,call_assigned ca,employee_master em,item_master im";
	//		calldisplay=calldisplay+" where ce.customer_id=cm.customer_id ";
	//		calldisplay=calldisplay+" and ce.callentry_id=ca.callentry_id ";
 	//		calldisplay=calldisplay+" and ca.employee_id=em.emp_id ";
 	//		calldisplay=calldisplay+" and ca.item_id=im.item_id ";
 	//		calldisplay=calldisplay+" and  ce.call_nature_id=cn.call_nature_id ";
 	//		calldisplay=calldisplay+" and ce.call_status='ASSIGNED' ";
 	//		calldisplay=calldisplay+" and ce.status='V'";
 	//		calldisplay=calldisplay+" order by ce.callentry_id";
    // PreparedStatement calldisplayprs=con.prepareStatement(calldisplay);
     //ResultSet calldisplayrs=calldisplayprs.executeQuery();*/
     String calltypestaus="ASSIGNED";
     CallableStatement cstmt = null;
		ResultSet calldisplayrs = null;
		
		//out.print("role_id "+role_id);
            
		
		    if(role_id == 2)
            {	cstmt = con.prepareCall("{?=call fun_retrieve_callassigrolewise(?,?,?)}");
            	cstmt.registerOutParameter(1, Types.OTHER);
		    	cstmt.setString(2, calltypestaus);
		    	cstmt.setInt(3, emp_id);  //emp_id is id of the employee who logged in from session 
		       	cstmt.setObject(4, calldisplayrs);
		
            }
            else
            {	cstmt = con.prepareCall("{?=call fun_retrieve_callassigned(?,?)}");
                cstmt.registerOutParameter(1, Types.OTHER);
			    cstmt.setString(2, calltypestaus);
			    cstmt.setObject(3, calldisplayrs);
            }
			    
			    
			 con.setAutoCommit(false);
			cstmt.execute();
			
			calldisplayrs =(ResultSet) cstmt.getObject(1);	
 	
    while(calldisplayrs.next())
     {flag=true;count++;
     callentry_id= calldisplayrs.getString(1);
     complaint_id=calldisplayrs.getString(2);
     customer_name=calldisplayrs.getString(3);
     area=calldisplayrs.getString(4);
     cust_type=calldisplayrs.getString(5);
     call_details=calldisplayrs.getString(6);
      emp_id1= calldisplayrs.getString(7);
      cust_id= calldisplayrs.getString(8);
      item_name=calldisplayrs.getString(9);
      String servicelink="<a href='/Genius/form/general/ServiceCall.jsp?complaint_id="+complaint_id+"&emp_id="+emp_id1+"&cust_id="+cust_id+"&item_name="+item_name;
      String resetlink="<a href='/Genius/form/general/ResetCallAssign.jsp?complaint_id="+complaint_id+"&emp_id="+emp_id1+"&cust_id="+cust_id+"&item_name="+item_name;

  // callentry_id
   %>
   
 
   <tr>
    <td colspan=1><font size=2 color="BLACK"><%=servicelink+"'>"%><%=count%></a></font></td>
    <td colspan=1><font size=2 color="BLACK"><%=servicelink+"'>"%><%=complaint_id %></a></font></td>
    <td colspan=1><font size=2 color="BLACK"><%=servicelink+"'>"%><%=customer_name %></a></font></td>
    <td colspan=1><font size=2 color="BLACK"><%=servicelink+"'>"%><%=area %></a></font></td>
    <td colspan=1><font size=2 color="BLACK"><%=servicelink+"'>"%><%=item_name %></a></font></td>
    <td colspan=1><font size=1 color="BLACK"><%=servicelink+"'>"%><%=call_details.toUpperCase()%></a></font></td>           
    <td colspan=1>
    <select name="<%=("employee_id"+callentry_id)%>"  disabled onclick="customersel(this)">
    <option value="0">--select---</option>
    <%  
   String employee="select emp_id,(name||' ' ||last_name) as emp_name from employee_master where role_id!=1 and  status='V'";
   
    PreparedStatement employeeprs=con.prepareStatement(employee);
    ResultSet employeers=employeeprs.executeQuery();
     while(employeers.next())  {
     emp_eid= employeers.getString(1);
    if(emp_eid.equalsIgnoreCase(emp_id1))
    {
     %>
     
      
     
     <option readonly selected value=<%=(callentry_id+"#"+employeers.getString(1))%>><font size=1 color="BLACK"><%=employeers.getString(2) %></font></option>
   <%}else{ %>
        <option readonly value=<%=(callentry_id+"#"+employeers.getString(1))%>><font size=1 color="BLACK"><%=employeers.getString(2) %></font></option>
    <%}
    
	
    
    
    }%>  
      </select>
     </td>
     <%if(role_id <2) {%>
     <td colspan=1><font size=1 color="BLACK"><%=resetlink+"'>"%>SEND TO REASSIGN</a></font></td>           
     
     <%
     }
    }
    %>
   
   
   </tr>
  
   
    
   

   </table>
<% 
    }
    catch(Exception e)
    {e.printStackTrace();}
     
      %>
  </body>
</html>
